<template>
  <el-card>
    <div slot="header">
      <strong>实验报告</strong>
    </div>
    <el-row>
      <el-table :data="source">
        <el-table-column label="姓名" prop="username"></el-table-column>
        <el-table-column label="学校/单位" prop="school"></el-table-column>
        <el-table-column label="实验课程" prop="courseName"></el-table-column>
        <el-table-column
          label="实验名称"
          prop="experimentName"
        ></el-table-column>
        <!-- <el-table-column label="创建时间">
          <template slot-scope="scope">{{
            $parseDate(scope.row.createTime)
          }}</template>
        </el-table-column> -->
        <el-table-column label="时长">
          <template slot-scope="scope">{{ scope.row.duration }}分钟</template>
        </el-table-column>
        <el-table-column label="得分">
          <template slot-scope="scope">
            <span>{{ scope.row.totalScore }}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button @click="openReport(scope.row.id)">查看报告</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-row>
    <el-pagination
      :page-size="size"
      :current-page.sync="page"
      :total="total"
      @current-change="load"
    ></el-pagination>
    <ReportDialog :visible.sync="showReport" :id="recordId"></ReportDialog>
    <!-- <RecordDetailDialog
      :id="recordId"
      :visible.sync="showDetail"
    ></RecordDetailDialog> -->
  </el-card>
</template>
<script>
// import RecordDetailDialog from '../../../components/dialog/RecordDetailDialog.vue'
import ReportDialog from '../../../components/dialog/ReportDialog.vue'

import RApi from '../../../api/ExpRecord.js'
export default {
  data() {
    return {
      page: 1,
      size: 15,
      total: 0,
      recordId: 0,
      showReport: false,
      source: [],
      record: {},
      showDetail: false
    }
  },
  components: {
    // RecordDetailDialog,
    ReportDialog
  },
  methods: {
    parseSeconds(s) {
      if (s) {
        let second = s % 60
        let minit = s / 60
        return `${parseInt(minit)}:${second}`
      }
      return '0'
    },
    openDetail(record) {
      this.showDetail = true
      this.recordId = record
    },
    openReport(id) {
      this.showReport = true
      this.recordId = id
      //   window.location.href = 'http://192.168.0.156:7000/user/download/1'
    },
    load() {
      this.axios
        .get(RApi.findAll, {
          params: {
            pageNum: this.page,
            pageSize: this.size
          }
        })
        .then(res => {
          if (res.data.status === 0) {
            window.console.log(res)
            this.source = res.data.data.list
            window.console.log(this.source)
            this.total = res.data.data.total
          }
        })
    }
  },
  mounted() {
    this.load()
  }
}
</script>
<style></style>
